<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="50px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-4">
  <div class="opera-wrap">
    <button nz-button nzType="primary" (click)="showEditGoodsModal()">新增</button>
  </div>

  <div class="pagination-wrap-position p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center">69码</th>
          <th nzAlign="center">图片</th>
          <th nzAlign="center">商品名称</th>
          <th nzAlign="center">品牌</th>
          <th nzAlign="center">备注</th>
          <th nzAlign="center">操作</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- 69码 -->
          <td nzAlign="center">{{ data.code || '-' }}</td>
          <!-- 图片 -->
          <td nzAlign="center">
            <img
              nz-image
              width="42px"
              height="42px"
              [nzSrc]="data.img"
              [nzFallback]="fallback"
              alt=""
            />
          </td>
          <!-- 商品名称 -->
          <td nzAlign="center">{{ data.name || '-' }}</td>
          <!-- 品牌 -->
          <td nzAlign="center">{{ data.brandName || '-' }}</td>
          <!-- 备注 -->
          <td nzAlign="center">{{ data.remark || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center">
            <button nz-button nzType="link" (click)="showEditGoodsModal(data)">编辑</button>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>

<!-- S 新增编辑 -->
<nz-modal
  nzClassName="custom-model-wrap"
  [nzFooter]="null"
  [nzMaskClosable]="false"
  [(nzVisible)]="isVisible"
  [nzTitle]="modalItem ? '编辑' : '新增'"
  (nzOnCancel)="isVisible = false">

  <div *nzModalContent>
    <div class="custom-model-body">
      <form nz-form [formGroup]="validateForm">
        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>69码</nz-form-label>
          <nz-form-control [nzSpan]="20" nzErrorTip="请输入69码!">
            <input
              nz-input
              placeholder="请输入69码"
              formControlName="code"
            />
          </nz-form-control>
        </nz-form-item>

        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>商品名称</nz-form-label>
          <nz-form-control [nzSpan]="20" nzErrorTip="请输入商品名称!">
            <input
              nz-input
              placeholder="请输入商品名称"
              formControlName="name"
            />
          </nz-form-control>
        </nz-form-item>

        <nz-form-item>
          <nz-form-label [nzSpan]="4" nzRequired>状态</nz-form-label>
          <nz-form-control [nzSpan]="20" nzErrorTip="请选择状态!">
            <nz-radio-group formControlName="state">
              <label nz-radio [nzValue]="0">禁用</label>
              <label nz-radio [nzValue]="1">启用</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>

        <nz-form-item>
          <nz-form-label [nzSpan]="4">品牌</nz-form-label>
          <nz-form-control [nzSpan]="20">
            <input
              nz-input
              placeholder="请输入品牌"
              formControlName="brandName"
            />
          </nz-form-control>
        </nz-form-item>

        <nz-form-item>
          <nz-form-label [nzSpan]="4">图片</nz-form-label>
          <nz-form-control [nzSpan]="20">
            <zdy-upload
              formControlName="img"
            ></zdy-upload>
          </nz-form-control>
        </nz-form-item>

        <nz-form-item>
          <nz-form-label [nzSpan]="4">备注</nz-form-label>
          <nz-form-control [nzSpan]="20">
            <nz-textarea-count [nzMaxCharacterCount]="200">
              <textarea
                rows="4"
                nz-input
                maxlength="200"
                placeholder="仅内部可见"
                formControlName="remark"
              ></textarea>
            </nz-textarea-count>
          </nz-form-control>
        </nz-form-item>
      </form>
    </div>

    <div class="custom-model-foot">
      <div class="custom-foot-cont">
        <button nz-button nzType="default" (click)="isVisible = false">取消</button>
        <button nz-button nzType="primary" [nzLoading]="submitLoading" (click)="submitForm()">确定</button>
      </div>
    </div>
  </div>
</nz-modal>
<!-- E 新增编辑 -->